import { CarItem } from "./carReducer";

// 常量
export const ADD_CAR = "ADD_CAR";
export const DELETE_CAR = "DELETE_CAR";

export const ADD_CAR_COUNT = "ADD_CAR_COUNT";
export const SUB_CAR_COUNT = "SUB_CAR_COUNT";

export const SWITCH_CAR_CHECK = "SWITCH_CAR_CHECK"


interface AddCar {
  type: typeof ADD_CAR;
  payload: CarItem;
}
// 工厂函数
export function addCar(payload: CarItem): AddCar {
  return { type: ADD_CAR, payload };
}

interface AddCarCount {
  type: typeof ADD_CAR_COUNT;
  payload: string;
}

export function addCarCount(payload: string): AddCarCount {
  return { type: ADD_CAR_COUNT, payload };
}

interface SubCarCount {
  type: typeof SUB_CAR_COUNT;
  payload: string;
}

export function subCarCount(payload: string): SubCarCount {
  return { type: SUB_CAR_COUNT, payload };
}

interface DeleteCar {
  type: typeof DELETE_CAR;
  payload: string;
}

export function deleteCar(payload: string): DeleteCar {
  return { type: DELETE_CAR, payload };
}



interface SwitchCarCheck {
  type: typeof SWITCH_CAR_CHECK;
  payload: string;
}

export function switchCarCheck(payload: string): SwitchCarCheck {
  return { type: SWITCH_CAR_CHECK, payload };
}
// action类型
export type CarAction = AddCar | AddCarCount | SubCarCount | DeleteCar | SwitchCarCheck;
